package cn.cy.dao.orclimpl;

import cn.cy.dao.BaseDao;
import cn.cy.dao.SysEmployeeDao;
import cn.cy.pojo.SysEmployee;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository("sysEmployeeDao")
public class SysEmployeeDaoImpl extends BaseDao implements SysEmployeeDao {
    public SysEmployeeDaoImpl(){}
    @Autowired
    public SysEmployeeDaoImpl(@Qualifier("sessionFactory") SessionFactory sessionFactory){
        this.setSessionFactory(sessionFactory);
    }

    @Override
    public SysEmployee findByNameAndPwd(SysEmployee sysEmployee) {
        String hql = "from SysEmployee where sn=? and password=? ";
        List<SysEmployee> list = this.getHibernateTemplate().find(hql,sysEmployee.getSn(),sysEmployee.getPassword());
        if(list != null && list.size() > 0 ){
            return list.get(0);
        }else{
            return new SysEmployee();
        }
    }
}
